package monopoly;


public class chance {
        public static void player() {
                dice.dice_roll(vars.chance);
                System.out.println("You reveal a card from chance");
                System.out.print("The revealed card is: ");
                if (vars.chance == 1) {
                        System.out.println("Advance to Go (Collect $200)");
                        vars.player_position = 0;
                        vars.player_money = vars.player_money + 200;
                }
                if (vars.chance == 2) {
                        System.out
                                        .println("Advance to Illinois Ave - if you pass Go, collect $200");
                        if (vars.player_position > 24) {
                                vars.player_money = vars.player_money + 200;
                                System.out.println("You pass go and collect $200");
                        }
                        vars.player_position = 24;
                }
                if (vars.chance == 3) {
                        System.out
                                        .println("Advance token to nearest Utility. If unowned, you may buy it from the Bank. If owned, throw dice and pay owner a total ten times the amount thrown.");
                        if (vars.player_position < 12 || vars.player_position > 28) {
                                System.out.println("You advance to the Electric Company");
                                if (vars.player_position > 28) {
                                        System.out
                                                        .println("You pass go on your way there and collect $200");
                                        vars.player_money = vars.player_money + 200;
                                }
                                vars.player_position = 12;
                        } else {
                                System.out.println("You advance to Water Works");
                                vars.player_position = 28;
                        }

                        player.pay_rent();
                }
                if (vars.chance == 4) {
                        System.out.println("Advance token to the nearest Railroad and pay owner twice the rental to which he/she is otherwise entitled. If Railroad is unowned, you may buy it from the Bank.");
                        if (vars.player_position == 7) {
                                vars.player_position = 15;
                        } else if (vars.player_position == 22) {
                                vars.player_position = 25;
                        } else if (vars.player_position == 36) {
                                vars.player_position = 5;
                        }
                        System.out.println("You advance to "
                                        + arrays.property_name[vars.player_position] + ".");
                        if (arrays.property_type[vars.player_position] == 0) {
                                player.buy_property();
                        } else if (arrays.property_type[vars.player_position] == 1) {
                                System.out.println("You alreadly own "
                                                + arrays.property_name[vars.player_position] + ".");
                        } else {
                                vars.var = player.railroadRent();
                                System.out.println("You land on"
                                                + arrays.property_name[vars.player_position]
                                                + " and are charged $" + vars.var*2 + ".");
                                vars.player_money = vars.player_money - vars.var*2;
                                vars.computer_money = vars.computer_money + vars.var*2;
                        }
                }
                if (vars.chance == 5) {
                        System.out
                                        .println("Advance to St. Charles Place  if you pass Go, collect $200");
                        System.out.println("You advance to St. Charles Place");
                        if (vars.player_position > 11) {
                                System.out.println("You pass go and collect $200");
                                vars.player_money = vars.player_money + 200;
                        }
                        vars.player_position = 11;
                        if (arrays.property_type[vars.player_position] == 0) {
                                player.buy_property();
                        } else if (arrays.property_type[vars.player_position] == 1) {
                                System.out.println("You alreadly own "
                                                + arrays.property_name[vars.player_position] + ".");
                        } else {
                                player.pay_rent();
                        }
                }
                if (vars.chance == 6) {
                        System.out.println("Bank pays you dividend of $50");
                        vars.player_money = vars.player_money + 50;
                }
                if (vars.chance == 7) {
                        System.out.println("Go back 3 spaces");
                        vars.player_position = vars.player_position - 3;
                }
                if (vars.chance == 8) {
                        System.out.println("Go directly to Jail  do not pass Go, do not collect $200");
                        vars.player_position = 10;
                        vars.player_jail = 1;
                }
                if (vars.chance == 9) {
                        System.out.println("Pay poor tax of $15");
                        vars.player_money = vars.player_money - 15;
                }
                if (vars.chance == 10) {
                        System.out.println("Take a trip to Reading Railroad  if you pass Go, collect $200");
                        System.out.println("You advance to Reading Railroad.");
                        System.out.println("You pass go and collect $200");
                        vars.player_position = 5;
                        vars.player_money = vars.player_money + 200;
                        if (arrays.property_type[vars.player_position] == 0) {
                                player.buy_property();
                        } else if (arrays.property_type[vars.player_position] == 1) {
                                System.out.println("You alreadly own Reading Railroad.");
                        } else {
                                player.pay_rent();
                                
                        }
                }
                if (vars.chance == 11) {
                        System.out
                                        .println("Take a walk on the Boardwalk  advance token to Boardwalk");
                        System.out.println("You advance to Boardwalk");
                        vars.player_position = 39;
                        if (arrays.property_type[vars.player_position] == 0) {
                                player.buy_property();
                        } else if (arrays.property_type[vars.player_position] == 1) {
                                System.out.println("You alreadly own "
                                                + arrays.property_name[vars.player_position] + ".");
                        } else {
                                player.pay_rent();
                        }

                }
                if (vars.chance == 12) {
                        System.out.println("You have been elected chairman of the board  pay each player $50");
                        System.out.println("You pay the computer $50");
                        vars.player_money = vars.player_money - 50;
                        vars.computer_money = vars.computer_money + 50;
                }
                if (vars.chance == 13) {
                        System.out.println("You have won a crossword competition - collect $100");
                        System.out.println("You collect $100");
                        vars.player_money = vars.player_money + 100;
                }
        }

        public static void computer() {
                System.out.println("The computer reveals a card from chance");
                System.out.print("The revealed card is: ");
                if (vars.chance == 1) {
                        System.out.println("Advance to Go (Collect $200)");
                        vars.computer_position = 0;
                        vars.computer_money = vars.computer_money + 200;
                }
                if (vars.chance == 2) {
                        System.out.println("Advance to Illinois Ave - if you pass Go, collect $200");
                        if (vars.computer_position > 24) {
                                vars.computer_money = vars.computer_money + 200;
                                System.out.println("The Computer passes go and collects $200");
                        }
                        vars.computer_position = 24;
                        if (arrays.property_type[vars.computer_position] == 0) {
                                System.out.println("The Computer bought "
                                                + arrays.property_name[vars.computer_position] + ".");
                                vars.computer_money = vars.computer_money
                                                - arrays.property_price[vars.computer_position];
                                arrays.property_type[vars.computer_position] = 2;
                        } else if (arrays.property_type[vars.computer_position] == 2) {
                                System.out.println("The Computer alreadly owns "
                                                + arrays.property_name[vars.computer_position] + ".");
                        } else {
                                System.out.println("You alreadly owns "
                                                + arrays.property_name[vars.computer_position] + ".");
                                System.out.println("The computer pays $"
                                                + arrays.property_rent[vars.computer_position]
                                                + " rent.");
                                vars.computer_money = vars.computer_money
                                                - arrays.property_rent[vars.computer_position];
                                vars.player_money = vars.player_money
                                                - arrays.property_rent[vars.computer_position];
                        }
                }
                if (vars.chance == 3) {
                        System.out
                                        .println("Advance token to nearest Utility. If unowned, you may buy it from the Bank. If owned, throw dice and pay owner a total ten times the amount thrown.");
                        if (vars.computer_position < 12 || vars.computer_position > 28) {
                                System.out
                                                .println("The Computer advances to the Electric Company");
                                if (vars.computer_position > 28) {
                                        System.out
                                                        .println("The computer passes go on its way there and collects $200");
                                        vars.computer_money = vars.computer_money + 200;
                                }
                                vars.computer_position = 12;
                        } else {
                                System.out.println("The Computer advances to Water Works");
                                vars.computer_position = 28;
                        }
                        if (arrays.property_type[vars.computer_position] == 2) {
                                System.out.println("The computer alreadly owns "
                                                + arrays.property_name[vars.computer_position]);
                        } else if (arrays.property_type[vars.computer_position] == 0) {

                                System.out.println("The computer buys "
                                                + arrays.property_name[vars.computer_position] + ".");
                                arrays.property_type[vars.player_position] = 2;
                                vars.computer_money = vars.computer_money
                                                - arrays.property_price[vars.computer_position];

                        } else if (arrays.property_type[vars.computer_position] == 1) {
                                System.out.println("You alreadly own "
                                                + arrays.property_name[vars.player_position] + ".");
                                vars.dice = dice.dice_roll(vars.dice);
                                vars.dice2 = dice.dice_roll(vars.dice2);
                                vars.var = vars.dice + vars.dice2;
                                System.out.println("The computer rolls a " + vars.var
                                                + " and pays you " + vars.var * 10 + ".");
                                vars.player_money = vars.player_money + (vars.var * 10);
                                vars.computer_money = vars.computer_money - (vars.var * 10);
                        }
                }
                if (vars.chance == 4) {
                        System.out
                                        .println("Advance token to the nearest Railroad and pay owner twice the rental to which he/she"
                                                        + " is otherwise entitled. If Railroad is unowned, you may buy it from the Bank.");
                        if (vars.computer_position == 7) {
                                vars.computer_position = 15;
                        } else if (vars.computer_position == 22) {
                                vars.computer_position = 25;
                        } else if (vars.computer_position == 36) {
                                vars.computer_position = 5;
                        }
                        System.out.println("The computer advances to "
                                        + arrays.property_name[vars.computer_position] + ".");
                        if (arrays.property_type[vars.computer_position] == 0) {

                                System.out.println("The computer bought "
                                                + arrays.property_name[vars.player_position] + ".");
                                vars.computer_money = vars.computer_money - 200;
                                arrays.property_type[vars.computer_position] = 1;

                        } else if (arrays.property_type[vars.computer_position] == 2) {
                                System.out.println("The computer alreadly owns "
                                                + arrays.property_name[vars.computer_position] + ".");
                        } else {
                                vars.var = 0;
                                if (arrays.property_type[5] == 2) {
                                        vars.var++;
                                }
                                if (arrays.property_type[15] == 2) {
                                        vars.var++;
                                }
                                if (arrays.property_type[25] == 2) {
                                        vars.var++;
                                }
                                if (arrays.property_type[35] == 2) {
                                        vars.var++;
                                }
                                if (vars.var == 1) {
                                        vars.var = 50;
                                }
                                if (vars.var == 2) {
                                        vars.var = 100;
                                }
                                if (vars.var == 3) {
                                        vars.var = 200;
                                }
                                if (vars.var == 4) {
                                        vars.var = 400;
                                }
                                System.out.println("The Computer lands on"
                                                + arrays.property_name[vars.player_position]
                                                + " and is charged $" + vars.var + ".");
                                vars.computer_money = vars.computer_money - vars.var;
                                vars.player_money = vars.player_money + vars.var;
                        }
                }
                if (vars.chance == 5) {
                        System.out
                                        .println("Advance to St. Charles Place  if you pass Go, collect $200");
                        System.out.println("The computer advances to St. Charles Place");
                        if (vars.computer_position > 11) {
                                System.out.println("The Computer passes go and collect $200");
                                vars.computer_money = vars.computer_money + 200;
                        }
                        vars.player_position = 11;
                        if (arrays.property_type[vars.computer_position] == 0) {
                                computer.buy_property();
                        } else if (arrays.property_type[vars.player_position] == 2) {
                                System.out.println("You alreadly own "
                                                + arrays.property_name[vars.player_position] + ".");
                        } else {
                                computer.pay_rent();
                        }
                }
                if (vars.chance == 6) {
                        System.out.println("Bank pays you dividend of $50");
                        System.out.println("The Computer receives $50");
                        vars.computer_money = vars.player_money + 50;
                }
                if (vars.chance == 7) {
                        System.out.println("Go back 3 spaces");
                        vars.computer_position = vars.computer_position - 3;
                }
                if (vars.chance == 8) {
                        System.out
                                        .println("Go directly to Jail  do not pass Go, do not collect $200");
                        vars.computer_position = 10;
                        vars.computer_jail = 1;
                }
                if (vars.chance == 9) {
                        System.out.println("Pay poor tax of $15");
                        vars.computer_money = vars.computer_money - 15;
                }
                if (vars.chance == 10) {
                        System.out
                                        .println("Take a trip to Reading Railroad  if you pass Go, collect $200");
                        System.out.println("The computer advances to Reading Railroad.");
                        System.out.println("The computer passes go and collects $200");
                        vars.computer_position = 5;
                        vars.computer_money = vars.computer_money + 200;
                        if (arrays.property_type[vars.computer_money] == 0) {
                                computer.buy_property();
                        } else if (arrays.property_type[vars.computer_money] == 1) {
                                System.out
                                                .println("The computer alreadly owns Reading Railroad.");
                        } else {
                                computer.pay_rent();
                        }
                        if (vars.chance == 11) {
                                System.out
                                                .println("Take a walk on the Boardwalk  advance token to Boardwalk");
                                System.out.println("The computer advances to Boardwalk");
                                vars.computer_position = 39;
                                if (arrays.property_type[vars.computer_position] == 0) {
                                        computer.buy_property();
                                } else if (arrays.property_type[vars.computer_position] == 1) {
                                        System.out.println("You alreadly own "
                                                        + arrays.property_name[vars.player_position] + ".");
                                } else {
                                        computer.pay_rent();
                                }
                        }
                        if (vars.chance == 12) {
                                System.out
                                                .println("You have been elected chairman of the board  pay each player $50");
                                System.out.println("The computer pays you $50");
                                vars.player_money = vars.player_money + 50;
                                vars.computer_money = vars.computer_money - 50;
                        }
                        if (vars.chance == 13) {
                                System.out
                                                .println("You have won a crossword competition - collect $100");
                                System.out.println("The computer collects $100");
                                vars.computer_money = vars.computer_money + 100;
                        }
                }
        }
}